package com.lantosec.hmrp.modules.notify.service.impl;

import com.lantosec.hmrp.core.shiro.TokenUtil;
import com.lantosec.hmrp.core.util.DateUtils;
import com.lantosec.hmrp.modules.notify.entity.NotifyPublicRead;
import com.lantosec.hmrp.modules.notify.mapper.NotifyPublicReadMapper;
import com.lantosec.hmrp.modules.notify.service.INotifyPublicReadService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lantosec.hmrp.modules.notify.vo.NotifyPublicReadVO;
import org.springframework.stereotype.Service;
import org.springframework.context.annotation.Primary;
import lombok.extern.log4j.Log4j2;

import java.util.List;

/**
 * <p>
 * 公告读看信息 服务实现类
 * </p>
 *
 * @author AutoCode
 * @since 2020-05-22
 */
@Service
@Primary
@Log4j2
public class NotifyPublicReadServiceImpl extends ServiceImpl<NotifyPublicReadMapper, NotifyPublicRead> implements INotifyPublicReadService {

    @Override
    public void insertNotifyPublicRead(List<NotifyPublicReadVO> notifyPublicReadVOList) {
        notifyPublicReadVOList.forEach(param->{
            //获取当前用户id
            String userId = TokenUtil.getUserId();
            param.setUserId(userId);
            param.setReadTime(DateUtils.nowDate());
            this.save(param.convertToEntity());
        });
    }
}
